package cn.wolfcode.luowowo2.articleserver.service.imp;

import cn.wolfcode.luowowo2.article.domain.StrategyTheme;
import cn.wolfcode.luowowo2.article.mapper.StrategyThemeMapper;
import cn.wolfcode.luowowo2.article.service.IStrategyThemeService;
import cn.wolfcode.luowowo2.common.query.StrategyThemeQueryObject;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * Created by Albert on 2019/7/9.
 */
@Service
public class StrategyThemeServiceImpl implements IStrategyThemeService {
    @Autowired
    private StrategyThemeMapper mapper;
    @Override
    public PageInfo<StrategyTheme> query(StrategyThemeQueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        List<StrategyTheme> list = mapper.selectForList(qo);
        return new PageInfo<>(list);
    }

    @Override
    public void saveOrUpdate(StrategyTheme strategyTheme) {
        if (strategyTheme.getId()==null) {
            mapper.insert(strategyTheme);
        }else {
            mapper.updateByPrimaryKey(strategyTheme);
        }
    }

    @Override
    public List<StrategyTheme> listAll() {
        return mapper.selectAll();
    }

}
